package com.suixinsanren.design.compound.study.demo04;

/**
 * 鸭子叫声计数器，统计鸭子叫声次数（使用装饰模式，避免修改鸭子类代码）
 */
public class QuackCounter implements Quackable {

    private Quackable duck;
    private static int numberOfQuacks;

    public QuackCounter(Quackable duck) {
        this.duck = duck;
    }

    @Override
    public void quack() {
        duck.quack();
        numberOfQuacks++;
    }

    public static int getQuacks() {
        return numberOfQuacks;
    }
}
